var merchant = globalFun.GetQueryString("merchant_id");
var id = globalFun.GetQueryString("id");
var hunterId = globalFun.GetQueryString("hunter_id");
var tid = globalFun.GetQueryString("topicId");
var hid = globalFun.GetQueryString("share");
//选择分类按钮 蒙版规格出现
$("#guiG").click(function() {
  $('.mengban').show();
  $('.box').show();
});
//查看评价跳转
$(".sppj-z p").click(function() {
  var type = $(this).attr("type");
  window.location.href = "../homektxq/shangpinpingjia.html?spId=" + spId + "&type=" + type;
});
//查看全部评价跳转

$(".sppj-4").click(function() {
  var type = $(this).attr("type");
  var src = $("#mySwipe .swipe-wrap div:first-child img").attr("src")
  sessionStorage.setItem('dai', src);
  window.location.href = "../homektxq/shangpinpingjia.html?spId=" + spId + "&type=" + type;
   var dataObj = {
			    type: 1,
			    id: user_info.id,
			    uuid: user_info.uuid,
			    phone: user_info.phone,
			    url: location.href + '&share=' + user_info.id,
			    title: title,
			    content: content,
			    hunterId: hunterId
  	}
  sessionStorage.setItem("poduct",JSON.stringify(dataObj));
});
//滚动变化
$(".waimian").scroll(function() {
  if ($(this).scrollTop() == 0) {
    $(".shop_smallpic").hide();
  } else {
    $(".shop_smallpic").show();
  }
});
/* 分享 */
function toAppShare(data, self) {
  if ($(self).hasClass("disabled")) {
    return false
  }
  $(self).addClass("disabled")
  setTimeout(function() {
    $(self).removeClass("disabled")
  }, 1000)
  if (Auth()) {

  } else {
    // toClientLogin(location.href)
    // return false;
  }
  var JSONstr = JSON.stringify(data);
  if (mark === 0) {
    //var result = lase;
    window.stub.jsToClientShare(JSONstr); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。
  } else if (mark === 1) {
    //在改function 中添加原生调起js方法
    setupWebViewJavascriptBridge(function(bridge) {
      bridge.callHandler('jsToClientShare', data, function(resp) {});
    });
  }

}
$(".navFx-img").click(function() {
  var dataObj = {
    type: 1,
    id: user_info.id,
    uuid: user_info.uuid,
    phone: user_info.phone,
    url: location.href + '&share=' + user_info.id,
    title: title,
    content: content,
    hunterId: hunterId
  }
  toAppShare(dataObj, this)
})


// 客服
function customerService(dataObj) {
var ua = navigator.userAgent.toLowerCase();
if (mark == 1) {
    setupWebViewJavascriptBridge(function(bridge) {
      bridge.callHandler('jsCustomerService',dataObj,function(resp) {});
    });
} else if (mark == 0) {
    //var result = lase;
    var JSONstr = JSON.stringify(dataObj);
    window.stub.jsCustomerService(JSONstr); //用接口stub, 通过调用内部类中的方法jsMethod给javas传回result。

}
}
$('.kefu').on('click', function() {
var $self = $(this);
if ($self.hasClass("dis")) {
    return false
}
$self.addClass("dis")
setTimeout(function() {
    $self.removeClass("dis")
}, 1000)

if (Auth()) {
	var dataObj = {
    nikeName: nc,
    imgUrl: img,
    uuid: imId
}
console.log(dataObj)
customerService(dataObj)

} else {
		toClientLogin(location.href);
}
})
/* 返回按钮 */
$("#go_back").click(function() {
  var from = globalFun.GetQueryString("from");
  if (from == "app") {
    if (mark == 1) {
      setupWebViewJavascriptBridge(function(bridge) {
        bridge.callHandler('goBack', function(resp) {});
      });
    } else if (mark == 0) {
      //var result = lase;
      window.stub.goBack(); //用接口stub, 通过调用内部类中的方法jsMethod给javas传回result。

    }
  } else {
    window.history.go(-1)
  }

});


var num = 1;
var sp;
var spbol = false;
var mrz;
var spId; //商品id
var productTypeId; //商品分类id
var ggid; //规格id
var guiGeLength;
var gg_selected = false;


$('.btn').click(function() {
  if ($('.btn').hasClass('goBuy')) {
    gouMai()
  } else if($('.btn').hasClass('zz')){
    tianJia()
  }
  	gshop();
})

function gshop(){
	var content = [];
  $(".boxb-list .bianred").each(function() {
    content.push($(this).html())
  })
  $("#guiG span").html(content.join(" "));
$('.mengban').hide();
$('.box').hide();
}
// 提示添加购物车成功
function tianJia() {
  if (Auth()) {
    if (num > 0 && gg_selected) {
      var dataObj = {
        uuid: user_info.uuid,
        phone: user_info.phone,
        spid: $('#guize').val(),
        hunterid: hunterId,
        num: num,
        typeid: productTypeId, //商品分类id
        productid: spId, //商品id
        merchantid: merchant
      }
      $.ajax({
        type: "post",
        url: apicom + "mobile/after/shopcart/add",
//				url:"http://192.168.30.232:10001/mobile/after/shopcart/add",
        data: dataObj,
        async: false,
        dataType: "json",
        success: function(res) {
          console.log(res)
          if (typeof(res) == 'string') {
            res = JSON.parse(res);
          }
          if (res.code == 1) {
            tips('添加购物车成功')
            $('.mengban').hide();
            $('.box').hide();
            // 购物车数量
            var dataObj = {
              id: id,
              phone: user_info.phone,
              type: 0,
              hunterId: hunterId,
              memberId: user_info.id,
              merchantId: merchant
            }
            $.ajax({
              type: "post",
              url: apicom + "mobile/view/product/selectproductdetail",
              data: dataObj,
              async: false,
              dataType: "json",
              success: function(res) {
                if (typeof(res) == 'string') {
                  res = JSON.parse(res);
                }
                $('.carnum').show();
                $('.carnum').html(res.content.shopCartNum);
              }
            })
          } else {
            tips(res.msg)
          }
        }
      })
    } else {
      tips('请选择商品属性')
    }
  } else {
    toClientLogin(location.href)
  }
}

// 点击立即购买 跳转到填写订单
var merchantId;

$(".buy").click(function() {
	$('.mengban').show();
  $('.box').show();
	if ($('#guize').val()) {
	 		 gouMai();
	 		 return
	 }

$('.btn').addClass("goBuy");
$('.btn').addClass("zz");

})
// 点击购物车 显示

$('.gwc').click(function(){
			$('.mengban').show();
		$('.box').show();
	 if ($('#guize').val()) {
	 		tianJia();
	 		return

	 }

	if($(".btn").hasClass("goBuy")){
		$(".btn").removeClass("goBuy");
	}
	 $('.btn').addClass("zz");

});

// 点击收回 收回
$('.box-right').click(function(){
	$('.boxb-list span').removeClass('bianred');
	$('.mengban').hide();
	$('.box').hide();
});


function gouMai() {
  if (Auth()) {
    if (num > 0 && gg_selected) {
      var dataObj = {
        id: user_info.id,
        productId: spId,
        productSpecificationId: $('#guize').val(),
        productType: 0,
        merchantId: merchant,
        hunterId: hunterId,
        uuid: user_info.uuid,
        phone: user_info.phone,
        num: num
      }
      $.ajax({
        type: "post",
        url: apicom + "mobile/after/orderPlace/buyNow",
//      url:"http://192.168.50.248:10001/mobile/after/orderPlace/buyNow",
        data: dataObj,
        async: false,
        dataType: "json",
        success: function(res) {
          console.log(res);
          if (typeof(res) == 'string') {
            res = JSON.parse(res);
          }
          if (1 == res.code) {

            res.content.spId = ggid;
            res.content.merchantId = merchant;
            console.log(res.content)
            if(tid==null){
              window.location.href = rootdomain + 'html/product-order/product-tjdd.html'
            }else{
              window.location.href = rootdomain + 'html/product-order/product-tjdd.html?topicid='+tid+'&share='+hid;
            }
            sessionStorage.setItem("shopCartIds", JSON.stringify(res.content));
            sessionStorage.setItem("zhuangt", 1);
          } else {
            tips(res.msg)
          }
          $('.mengban').show();
          $('.box').show();

        },
        error: function(err) {
          console.log(err);
        }
      })
    } else {
      tips('请选择商品属性')
    }
  } else {
    toClientLogin(location.href)
  }
}

$(".jian").click(function() {
  num--;
  if (num < 1) {
    num = 1
  } else if (num > mrz) {
    num = mrz;
  }
  var nownum = mrz - num
  $('.surplus').html(nownum)
  $('.num').html(num)
})
$(".jia").click(function() {
  num++;
  if (num < 1) {
    num = 1
  } else if (num > mrz) {
    num = mrz;
  }
  var nownum = mrz - num
  console.log(nownum)
  $('.surplus').html(nownum)
  $('.num').html(num)
})

var aa
// 点击 商品规格
var mrz2;
var mrtImg;

$('.box-b').on('click', 'span', function() {
  gg_selected = false;
  num = 1;
  if ($(this).hasClass('bianred')) {
    $(this).removeClass('bianred')
  } else {
    $(this).addClass('bianred').siblings().removeClass('bianred')
  }
  var $elem = $(".box-b .bianred")
  if ($elem.length == guiGeLength) {
    gg_selected = true;
    var aa = []
    $elem.each(function(i, elem) {
      aa.push($(elem).attr("data-id") / 1)
    })
    var temp;
    for (var i = 0; i < aa.length; i++) {
      for (var j = i + 1; j < aa.length; j++) {
        if (aa[i] > aa[j]) {
          temp = aa[i];
          aa[i] = aa[j];
          aa[j] = temp;
        }
      }
    }
    var aaStr = aa.join(",");


    var dataObj = {
      ids: aaStr
    }
    console.log(dataObj)
    $.ajax({
      type: "post",
      url: apicom + "mobile/view/product/selectspecification",
      data: dataObj,
      async: false,
      dataType: "json",
      success: function(res) {
        if (typeof(res) == 'string') {
          res = JSON.parse(res);
        }
        if (res.content.address == null || res.content.address == '') {
          res.content.address = mrtImg;
        }
        $('.box-pic img').attr('src', res.content.address);
        $('.maney-a').html(res.content.salePrice);
				$('#guize').val(res.content.id);
        console.log(res)
        productTypeId = res.content.productTypeId;
        ggid = res.content.id;
        mrz = res.content.num
        if (res.code == 0) {
          tips(res.msg)
        } else if (res.code == 1) {
          $('.surplus').html(res.content.num);
        }
      }
    })
  } else {
    $(".surplus").html(sessionStorage.getItem("inventory"))
  }
})


// 商品详情
// 测试地址  192.168.50.248:10001



var status;
var imga;
var title;
var content;
var nc;
var img;
var imId;
var lunboimg;


function details() {
  var dataObj = {
		 	id:id,
		 	phone:"",
		 	type:0,
		 	hunterId:hunterId,
		 	memberId:"",
		}
		if(Auth()){
			dataObj.phone=user_info.phone;
			dataObj.memberId=user_info.id;
		}
  $.ajax({
    type: "post",
    url: apicom + "mobile/view/product/selectproductdetail",
    data: dataObj,
    async: false,
    dataType: "json",

    success: function(res) {
      if (typeof(res) == 'string') {
        res = JSON.parse(res);
      }
      console.log(res);
      if (res.code == 0) {
        tips(res.msg)
      } else if (res.code == 1) {
        $(".head-mc").html(res.content.name);
        $(".head-js").html(res.content.title);

        if (res.content.minPrice == res.content.maxPrice) {
          $(".zong").html(res.content.minPrice);
        } else {
          $(".zong").html(res.content.minPrice + '-' + res.content.maxPrice);
        }

        $('.pingk').attr('src', res.content.image);
        $('.kuaidi').html(res.content.freightPrice)
        $(".yuexiao").html(res.content.saleNum);
        $(".head-city").html(res.content.address);
        if (res.content.planNum) {
          $(".jhbh").html(res.content.planNum);
          $('.cpjh-red').html(res.content.planTitle)
          $(".cpjh-plan").html(res.content.planDescription);
        } else {
          $(".cpjh").hide();
          $(".jh").hide();
        }

        if (res.content.status) {
        //1 已收藏   0 未收藏
        isFollow = res.content.status;
        if (isFollow == 0) {
          //      		$(".navFx-img img").attr("src","../../img/d_xin.png");
          $(".navDp-imga").removeClass("red");
        } else {
          //      		$(".navFx-img img").attr("src","../../img/d_xin.png");
          $(".navDp-imga").addClass("red");
        }
      } else {

      }

        // $(".xq-wen1").html(res.content.description);
        // $('.xq-img img').attr('src',res.content.image);
        $(".pingjiashu").html(res.content.allCommentNum);
        $(".hp").html(res.content.goodCommentNum);
        $(".zp").html(res.content.secondCommentNum);
        $(".cp").html(res.content.badCommentNum);
        $(".cp").html(res.content.badCommentNum);

        //评论信息
//      if(){
//
//      }
//      var commentMsg = res.content.lastCommentMap.lastComment;
        //是否匿名
//      if (commentMsg == null) {
//        $(".sppj-2").html("");
//        $(".sppj-3").html("");
//      } else {
//        if (commentMsg.anonymity == 1) {
//          commentMsg.memberName = commentMsg.memberName;
//        } else {
//          if (commentMsg.memberName.length > 2) {
//            var xxStr = '';
//            for (var i = 0; i < commentMsg.memberName.length - 2; i++) {
//              xxStr += "*";
//            }
//            commentMsg.memberName = commentMsg.memberName.substr(0, 1) + xxStr + commentMsg.memberName.substr(commentMsg.memberName.length - 1, commentMsg.memberName.length);
//
//
//          } else if (commentMsg.memberName.length == 2) {
//            commentMsg.memberName = "**";
//          } else if (commentMsg.memberName.length == 1) {
//            commentMsg.memberName = "*";
//          }
//        }

         if( res.content.lastCommentMap == null ||  res.content.lastCommentMap.lastComment == null){
      			$(".sppj-2").html("");
      			$(".sppj-3").html("");
      			$('#pingjia_content').css('display', 'none');
      		}else{
      			var commentMsg=  res.content.lastCommentMap.lastComment;
             if(commentMsg.anonymity==1){
                commentMsg.memberName=commentMsg.memberName;
            }else{
                if(commentMsg.memberName.length>2){
                    var xxStr='';
                    for(var i=0;i<commentMsg.memberName.length-2;i++){
                        xxStr+="*";
                    }
                    commentMsg.memberName=commentMsg.memberName.substr(0,1)+xxStr+commentMsg.memberName.substr(commentMsg.memberName.length-1,commentMsg.memberName.length);


                }else if(commentMsg.memberName.length==2){
                    commentMsg.memberName="**";
                }else if(commentMsg.memberName.length==1){
                    commentMsg.memberName="*";
                }
            }

          commentMsg.logo=commentMsg.logo?commentMsg.logo:"../../img/b_moren3x.png";
           $(".tx").attr("src", commentMsg.logo);
          $(".mingzi").html(commentMsg.memberName);
          $(".shijian").html(commentMsg.createdTime);
          $(".pcontent").html(commentMsg.content);
//        $(".shoppj1").attr('src', commentMsg.picture);
//        $(".shoppj2").attr('src', commentMsg.picture);
//        $(".shoppj3").attr('src', commentMsg.picture);
          $('.guigui').html(commentMsg.specificationName);
          var xxContent = '';
          for (var i = 0; i < commentMsg.startNum; i++) {
            xxContent += '<img src="../../img/d_staryou.png">';
          }
          for (var i = 0; i < (5 - commentMsg.startNum); i++) {
            xxContent += '<img src="../../img/d_starwu.png">';
          }
          $(".xxnum").html(xxContent);
        }


        $('.surplus').html(res.content.inventory);
        $('.maney-a').html(res.content.price);
        $('.box-pica').attr('src', res.content.image);

        $('.imgs').attr('src', res.content.advisor.imgUrl);
        $('.jianshen1').html(res.content.advisor.nikeName).attr("data-imid",res.content.advisor.imId);

        $('.city_l').html(res.content.advisor.provinceName + res.content.advisor.cityName + res.content.advisor.countyName);
        var content = '';
        for (var i = 0; i < 5; i++) {
          if (i < res.content.advisor.startNum) {
            content += '<img src = "../../img/d_staryou.png" />'
          } else {
            content += '<img src = "../../img/d_starwu.png" />'
          }
        }
        $('.service_xx').html(content);

        $('.pingl').html(res.content.advisor.content);
        // 详情
        for (var i = 0; i < res.content.productDetail.length; i++) {
          var spxqType = res.content.productDetail;
          if (spxqType[i].type == 0) {
            $('.xq-wen1').show();
            $('<p>' + spxqType[i].content + '</p>').appendTo($('.shop_cotent'))
            //$(".xq-wen1 p").html(spxqType[i].content);
          } else if (spxqType[i].type == 1) {
            $('.xq-img').show();
            $('<div class="shop_pic" style="background-image:url(' + spxqType[i].content + ')"></div>').appendTo($('.shop_cotent'))
            //$('<img src="' + spxqType[i].content + '" class="xq-imga">').appendTo($('.xq-img'))
          } else if (spxqType[i].type == 2) {
            $('.video').show();
            $('<source src="' + spxqType[i].content + '" type="video/mp4">').appendTo($('#video1'))
          }
          /*if (spxqType[i].type == 0) {
            $(".shop_cotent p").html(spxqType[i].content);
          } else if (spxqType[i].type == 1) {
            $('.shop_cotent >div').css({
              "background-image": spxqType[i].content
            });
          }*/
        }



        mrtImg = res.content.imgs;
        console.log(mrtImg)


        var kdf = res.content.freightPrice;
        imga = res.content.address;
        title = res.content.name;
        content = res.content.title;

        localStorage.setItem('freightPrice', kdf);

        var lunbotu = res.content.imgs;
        merchant = res.content.merchantId

        nc = res.content.merchantNickname;
        img = res.content.merchantImage;
        imId = res.content.merchantImId;

        mrz = res.content.inventory;
        sessionStorage.setItem("inventory", mrz)
        spId = res.content.id;
        status = res.content.status;

        if (status == 0) {
          $('.navDp-img').attr('type', "4")
          //        $('.navDp-imga').attr('src', '../../img/d_collection.png');
        } else {
          $('.navDp-img').attr('type', "7")
          //        $('.navDp-imga').attr('src', '../../img/d_yishoucang.png');
        }

        // 购物车数量
        if (res.content.shopCartNum == 0) {
          $('.carnum').hide();
        } else {

          $('.carnum').show();
          $('.carnum').html(res.content.shopCartNum);
        }

        guiGeLength = res.content.attributes.length

        /*首页轮播图*/
        lunboimg = res.content.imgs;

        $('#lunbo-zs').html(lunboimg.length);

        var lunbo = ''
        for (var j = 0; j < lunboimg.length; j++) {
          lunbo += '<div><a href="javascript:;"><img class="img-responsive" src="' + lunboimg[j] + '"/></a></div>'
        }
        $('.swipe-wrap').html(lunbo);
        $('.swipe-wrap1').html(lunbo)

        for (var i = 0; i < res.content.attributes.length; i++) {
          $('<div class="boxb-ba"><p class="zhongl">' + res.content.attributes[i].name + '</p><div class="boxb-list"></div></div>').appendTo($('.box-b'));
          for (var j = 0; j < res.content.attributes[i].value.length; j++) {
            $('<span data-id=' + res.content.attributes[i].value[j].id + '>' + res.content.attributes[i].value[j].name + '</span>').appendTo($('.boxb-list').eq(i))
          }
        }

      }
    },
    error: function(err) {
      console.log(err);
    }
  })
}


details()

// 最近一次评论
//if (Auth()) {
//var data = {
//  productId: spId,
//  uuid: user_info.uuid,
//  phone: user_info.phone
//}
//$.ajax({
//  type: "post",
//  url: apicom + "mobile/view/ordercomment/selectlastcomment",
//  data: data,
//  async: false,
//  dataType: "json",
//  success: function(res) {
//    console.log(res);
//    if (typeof(res) == 'string') {
//      res = JSON.parse(res);
//    }
//    if (res.code == 1) {
//      var resourse = res.content.lastComment;
//      if (!resourse) {
//        $('.pingjia_content').hide()
//      } else {
//        $('.pingjia_content').show();
//        $('.tx').attr('src', resourse.logo);
//        $('.sppjNc').html(resourse.memberName);
//        $('.sppj-3').html(resourse.content);
//      }
//    } else {
//
//    }
//
//  },
//  error: function(err) {
//    console.log(err)
//  }
//})
//} else {
//  toClientLogin(location.href)
//}


// 评价数量
//var data = {
//productId: id
//}
//$.ajax({
//type: "post",
//url: apicom + "mobile/view/ordercomment/getClassifyComment",
//data: data,
//async: false,
//dataType: "json",
//success: function(res) {
//  console.log(res);
//  if (typeof(res) == 'string') {
//    res = JSON.parse(res);
//  }
//  $('.sppj-zsl').html(res.content.sumComment);
//  $(".hp").html(res.content.goodComment);
//  $(".zp").html(res.content.mediumComment);
//  $(".cp").html(res.content.negativeComment);
//}
//})


//收藏服务
$('.navDp-imga').click(function() {
  var $this = $(this);
  if (!Auth()) {
    toClientLogin();
  } else {
    if ($(this).hasClass("red")) {
      $.ajax({
        type: "post",
        url: apicom + "mobile/after/memberfollow/collection",
        data: {
          consultationId: '',
          planId: '',
          uuid: user_info.uuid,
          phone: user_info.phone,
          type: 7,
          productId: spId,
//        memberId: user_info.id
        },
        success: function(res) {
          if (typeof res == "string") {
            var data = JSON.parse(res);
          } else {
            var data = res;
          }
          if (data.code == 1) {
            $this.removeClass("red")
            tips("取消收藏");
            //			        	location.reload();
          }
        },
        error: function(err) {
          tips("服务器错误!");
        }
      });
    } else {
      $.ajax({
        type: "post",
        url: apicom + "mobile/after/memberfollow/collection",
        data: {
          consultationId: '',
          planId: '',
          uuid: user_info.uuid,
          phone: user_info.phone,
          type: 4,
          productId: spId,
//        memberId: user_info.id
        },
        success: function(res) {
          if (typeof res == "string") {
            var data = JSON.parse(res);
          } else {
            var data = res;
          }
          if (data.code == 1) {
            $this.addClass("red")
            tips("收藏成功");
            //			        	location.reload();
          }
        },
        error: function(err) {
          tips("服务器错误!");
        }
      });
    }
  }

});

//
//var isHunter;
//if (Auth()) {
//var data = {
//  uuid: user_info.uuid,
//  phone: user_info.phone,
//  memberId: user_info.id
//}
//$.ajax({
//  type: "post",
//  url: apicom + "mobile/after/member/memberdetail",
//  data: data,
//  async: false,
//  dataType: "json",
//  success: function(res) {
//    if (typeof(res) == 'string') {
//      res = JSON.parse(res);
//    }
//    console.log(res);
//    if (res.content.isHunter == 0) {
//      isHunter = res.content.isHunter
//    } else {
//      isHunter = ''
//    }
//  },
//  error: function(err) {
//    console.log(err)
//  }
//})
//}
/* 跳转Ios App原生页面 */
if (mark === 1) {
  //在改function 中添加原生调起js方法
  setupWebViewJavascriptBridge(function(bridge) {
    //注册原生调起方法
    //参数1： buttonjs 注册flag 供原生使用，要和原生统一
    //参数2： data  是原生传给js 的数据
    //参数3： responseCallback 是js 的回调，可以通过该方法给原生传数据

    bridge.registerHandler("clientToJsShare", function(data, responseCallback) {
      shareCallBack(spId)
    });

  })
}
if (mark === 0) {
  function clientToJsShare() {
    shareCallBack(spId)
  }
}
///* 分享回调 */
//function shareCallBack(id) {
//var dataObj = {
//  type: 1,
//  id: id,
//  phone: user_info.phone,
//  uuid: user_info.uuid
//}
//$.ajax({
//  url: apicom + "mobile/after/share/share",
//  type: 'POST',
//  dataType: 'json',
//  data: dataObj,
//  success: function(result) {
//    var res;
//    if (typeof(result) == "string") {
//      res = JSON.parse(result);
//    } else {
//      res = result
//    }
//    if (res.code == 1) {
//      //需要进行的操作
//    }
//  },
//  error: function() {
//    //提示
//    layer.open({
//      content: '服务器连接失败',
//      skin: 'msg',
//      time: 2 //2秒后自动关闭
//    });
//  }
//})
//}

// 轮播图
$(function() {
  var elem = document.getElementById('mySwipe');
  window.mySwipe = Swipe(elem, {
    //4s一次轮播
    effect: 4000,
    type: 'bullets',
    disableScroll: false,
    callback: function(index, element) {
      $("#position li").eq(index).addClass("active").siblings().removeClass("active");
      $('#current-in').html(index + 1)
      console.log(index)
    }
  });
  $("#position li").click(
    function() {
      mySwipe.slide($(this).index());
    });
});
// 联系团队
function kefu(dataObj) {
  var ua = navigator.userAgent.toLowerCase();
  if (mark === 1) {
    setupWebViewJavascriptBridge(function(bridge) {
      bridge.callHandler('jsCustomerService', dataObj, function(resp) {});
    });
  } else if (mark === 0) {
    //var result = lase;
    var JSONstr = JSON.stringify(dataObj);
    window.stub.jsCustomerService(JSONstr); //用接口stub, 通过调用内部类中的方法jsMethod给javas传回result。

  }
}
$('.sever_kefu').click(function() {
    			var $self = $(this);
    			if($self.hasClass("disa")){
    				return false
    			}
    			$self.addClass("disa")
    			setTimeout(function(){
    				$self.removeClass("disa")
    			},1000)

    			if(Auth()){
    				var dataObj = {
    					nikeName: $('.jianshen1').html(),
    					imgUrl: $('.imgs').attr('src'),
    					uuid: $('.jianshen1').attr('data-imid'),
    				}
            console.log(dataObj)
    				kefu(dataObj);
    			} else{
    				sessionStorage.setItem('history', window.location.href);
    				toClientLogin(location.href);
    			}
});



$('.buycart').click(function() {
  location.href = "../shopDetail/cart.html";
});



$("#xiany").on("click", "li", function (){
 $(this).addClass("add_color").siblings().removeClass("add_color");
});
$('.bao_b').click(function () {
	$('.map_l').show();
	$('.map_l2').hide();
	$('.map_l3').hide();
	$('.map_l4').hide();
});
$('.pingjone').click(function () {
	$('.map_l2').show();
	$('.map_l').hide();
	$('.map_l3').hide();
	$('.map_l4').hide();

});
$('.fw_td').click(function () {
	$('.map_l3').show();
	$('.map_l2').hide();
	$('.map_l').hide();
	$('.map_l4').hide();
});
$('.x_q').click(function () {
	$('.map_l4').show();
	$('.map_l3').hide();
	$('.map_l2').hide();
	$('.map_l').hide();
});
//滚动变化
$(".waimian").scroll(function() {
  if ($(this).scrollTop() == 0) {
    $("#xiany").hide();
  } else {
    $("#xiany").show();
  }
});
$('.bao_b').click(function () {
	$("div").scrollTop(0);
});

$('.pingjone').click(function () {
	$("div").scrollTop(500);
});
$('.fw_td').click(function () {
	$("div").scrollTop(710);
});
$('.x_q').click(function () {
	$("div").scrollTop(1000);
});

	// 点击放大轮播图
	$('.liehome').on('click',function(){
		$('.blacklunbo').show();
		var elem = document.getElementById('mySwipe1');
		window.mySwipe = Swipe(elem, {
			//4s一次轮播
			effect: 4000,
			type: 'bullets',
			disableScroll:false,
			callback: function(index, element) {
				$("#position li").eq(index).addClass("active").siblings().removeClass("active");
					 }
				});
				$("#position li").click(
					function() {
						mySwipe.slide($(this).index());
				});
	})

	$('.blacklunbo').on('click',function(){
		$(this).hide();

	})